package ysq.xyg.base.extend.thread.factory;

import cn.hutool.core.date.DateUtil;
import ysq.xyg.base.util.BaseConstant;
import ysq.xyg.base.util.BaseUtil;
import ysq.xyg.base.util.SpringApplicationContextUtil;
import ysq.xyg.host.model.po.HostWatch;
import ysq.xyg.host.service.HostWatchService;

import java.util.TimerTask;

/**
 * 异步工厂（产生任务用）
 * 
 * @author liuhulu
 *
 */
public class AsyncFactory {

    /**
     * 操作日志记录
     */
    public static TimerTask saveHostWatch(final HostWatch hostWatch) {
        return new TimerTask() {
            @Override
            public void run() {
                HostWatchService hostWatchService = (HostWatchService)SpringApplicationContextUtil.getBean("hostWatchService");
                hostWatch.setId(BaseUtil.uId());
                hostWatch.setCreateTime(DateUtil.date());
                hostWatch.setRemoveTag(BaseConstant.BASE_REMOVE_TAG_NORMAL);
                hostWatchService.insert(hostWatch);
            }
        };
    }

}
